<?php
App::uses('AppModel', 'Model');
/**
 * SysWebsite Model
 *
 * @property SysCity $SysCity
 * @property SysArea $SysArea
 * @property ArticleCate $ArticleCate
 * @property TicketBook $TicketBook
 */
class SysWebsite extends AppModel {

/**
 * Display field
 *
 * @var string
 */
	public $displayField = 'title';

/**
 * Validation rules
 *
 * @var array
 */
	public $validate = array(
		'sys_city_id' => array(
			'numeric' => array(
				'rule' => array('numeric'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'sys_area_id' => array(
			'numeric' => array(
				'rule' => array('numeric'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'sign' => array(
			'notEmpty' => array(
				'rule' => array('notEmpty'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'title' => array(
			'notEmpty' => array(
				'rule' => array('notEmpty'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'sort' => array(
			'numeric' => array(
				'rule' => array('numeric'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'enable' => array(
			'numeric' => array(
				'rule' => array('numeric'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
	);

	//The Associations below have been created with all possible keys, those that are not needed can be removed

/**
 * belongsTo associations
 *
 * @var array
 */
	public $belongsTo = array(
		'SysCity' => array(
			'className' => 'Areas.Areas',
			'foreignKey' => 'sys_city_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'SysArea' => array(
			'className' => 'Areas.Areas',
			'foreignKey' => 'sys_area_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)
	);

	public function getEanbleSite(){
		return $this->find('list',array(
			'conditions'=>array('SysWebsite.enable'=>1),
			'order'=>'SysWebsite.sort ASC'	
		));
	}
	
	public function getSwitchSite(){
		return $this->find('all',array(
				'fields'=>array('SysWebsite.id','SysWebsite.title','SysWebsite.sign'),
				'conditions'=>array('SysWebsite.enable'=>1),
				'order'=>'SysWebsite.sort ASC'
		));
	}
}
